<!DOCTYPE html>

<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.2</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" id="uppass">

            <div class="layui-form-item">
                <label for="pass" class="layui-form-label">
                    旧密码
                </label>
                <div class="layui-input-inline">
                    <input type="hidden"  th:value="${session.login.account}" id="account" >
                    <input type="password" id="pass" name="oldPassword" required="" lay-verify="pass"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span> 6到16个字符
                </div>
            </div>
            <div class="layui-form-item">
                <label for="pass1" class="layui-form-label">
                    新密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="pass1" name="password1" required="" lay-verify="pass"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span> 6到16个字符
                </div>
            </div>
            <div class="layui-form-item">
                <label for="pass2" class="layui-form-label">
                    确认密码
                </label>
                <div class="layui-input-inline">
                    <input type="password" id="pass2" name="password2" required="" lay-verify="repass"
                           autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>两次密码要一致
                </div>
            </div>
            <div class="layui-form-item">
                <label for="pass2" class="layui-form-label">
                </label>
                <button class="layui-btn" type="button" id="but">
                    保存
                </button>
            </div>
        </form>
    </div>
</div>
<script src="../js/jquery-1.4.2.js"></script>
<script src="../js/common/ajaxcommon.js"></script>

<script>
    var token=getCookie("token");
    //点击提交
    $("#but").click(function () {
        var username=$("#account").val();
        // alert(username)
        var oldPassword=$("#pass").val();
        var password1=$("#pass1").val();
        var password2=$("#pass2").val();
        if (oldPassword!==""&&password1!==""&&password2!=="") {
            if(oldPassword.length>5&&oldPassword.length<17){
                if(password1.length>5&&password1.length<17){
                    if (password1===password2) {
                        requestAjax("emp/changePassword",{account:username,password:password2,oldpassword:oldPassword},function (data) {
                            // alert(data)
                            if (data){
                                alert("修改成功，请重新登录！");
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            } else {
                                layer.msg(data.msg)
                            }
                            return false;
                        });
                    }else
                        layer.msg("两次输入的密码不一致！")
                }else
                    layer.msg("新密码输入不规范！~请完善")
            }else
                layer.msg("旧密码输入不规范！~请完善")
        }else
            layer.msg("不能为空！~请完善内容！")
    });





</script>

</body>

</html>
